/*
 * ﻿Copyright (C) 2011-2013 NewMain Softech
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */
/**
 * 
 */
package com.newmainsoftech.aspectjutil.eventmanager.testmodels;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.newmainsoftech.aspectjutil.adviseutil.Util;
import com.newmainsoftech.aspectjutil.eventmanager.label.EventTrigger;

public class EventProducer {
	protected static final Logger logger = LoggerFactory.getLogger( EventProducer.class);
	
	@EventTrigger( value=SampleEventClass.PriceChange.class)
	protected int price;
	public final void setPrice(int price) {
		if ( logger.isDebugEnabled()) {
			String thisMethodInfo = Util.getCallingMethodInfo( Thread.currentThread().getStackTrace(), 1, 1).get( 0);
			logger.debug( 
					"Executing" + (( thisMethodInfo.indexOf( "]:") > 0) ? thisMethodInfo.substring( thisMethodInfo.indexOf( "]:") + 2) : thisMethodInfo)
					);
		}
		
		this.price = price;
	}


	@EventTrigger( value=SampleEventClass.CalculationEvent.class)
	public int calculate( int x, int y) {
		if ( logger.isDebugEnabled()) {
			String thisMethodInfo = Util.getCallingMethodInfo( Thread.currentThread().getStackTrace(), 1, 1).get( 0);
			logger.debug( 
					"Executing" + (( thisMethodInfo.indexOf( "]:") > 0) ? thisMethodInfo.substring( thisMethodInfo.indexOf( "]:") + 2) : thisMethodInfo)
					);
		}
		
		return x*y;
	}
}